package com.mashensoft;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class StudentAction extends ActionSupport implements ModelDriven<Student> {
	private Student student = new Student();

	public Student getModel() {
		return student;
	}

	public String Login() {
		HttpServletRequest request = ServletActionContext.getRequest();
		if (!"".equals(student.getsName()) && !"".equals(student.getPassword())) {
			if ("tom".equals(student.getsName()) && "123".equals(student.getPassword())) {
				request.setAttribute("student", student.getsName());
				return SUCCESS;
			} else {
				request.setAttribute("msg", "帐号或密码错误");
				return ERROR;
			}
		}
		return ERROR;

	}

}
